home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 6 / coreaids.zip / ERRORMSG.ASM < prev    next >
Assembly Source File  |  1987-06-25  |  6KB  |  176 lines

  1. ;    DESC:    Prints DOS error messages 1-18 and additional user   V1.01
  2. ;         supplied messages from 19 up. If the value of ERR_NUM is
  3. ;         0 control returns to the calling program with no effect.
  4. ;         If ERR_NUM is greater than the value of the maximum error
  5. ;         message then the message "No Error for This Value" is
  6. ;         displayed and control returns to DOS. If an error code is
  7. ;         displayed then control also returns to DOS. The memory
  8. ;         address where the error occured is displayed on exit.
  9. ;    IN:    *{ERR_NUM} error number where the possible legal values are:
  10. ;         1......Invalid Function Number
  11. ;         2......File Not Found
  12. ;         3......Path Not Found
  13. ;         4......Too Many Open Files (no handles left)
  14. ;         5......Access Denied
  15. ;         6......Invalid Handle
  16. ;         7......Memory Control Blocks Destroyed
  17. ;         8......Insufficient Memory
  18. ;         9......Invalid Memory Block Address
  19. ;        10......Invalid Environment
  20. ;        11......Invalid Format
  21. ;        12......Invalid Access Code
  22. ;        13......Invalid Data
  23. ;        14......This Error Does Not Exist
  24. ;        15......Invalid Drive Was Specified
  25. ;        16......Attempted To Remove The Current Directory
  26. ;        17......Not Same Device
  27. ;        18......No More Files
  28. ;        19......No Room For File(s) On Target Disk
  29. ;        20......No Filename(s) Specified
  30. ;        21......No Volume Label On Disk
  31. ;        22......Wrong Number of Parameters
  32. ;            >22.....No Error for This Value
  33. ;    SAMPLE:    Callm    ERRORMSG,<ERR_NUM>,
  34. ;    ##################################################################
  35.  
  36. ERRORMSD    Segment
  37. ADDR1        DW    0            ;error occurrence address.
  38. ADDR2        DW    0
  39.         DB    ':'
  40. ADDR3        DW    0
  41. ADDR4        DW    0
  42.         DB    ' in '
  43. NUMBER        DB    44
  44. MAXERR        DW    23            ;maximum error value.
  45. CALLER        DW    0            ;return location.
  46. SNAME        DB    'CoreTechs'
  47.                         ;error value conversion table.
  48. MSG        DB    'Invalid Function Number                   at' ;1
  49.         DB    'File Not Found                            at' ;2
  50.         DB    'Path Not Found                            at' ;3
  51.         DB    'Too Many Open Files (no handles left)     at' ;4
  52.         DB    'Access Denied                             at' ;5
  53.         DB    'Invalid Handle                            at' ;6
  54.         DB    'Memory Control Blocks Destroyed           at' ;7
  55.         DB    'Insufficient Memory                       at' ;8
  56.         DB    'Invalid Memory Block Address              at' ;9
  57.         DB    'Invalid Environment                       at' ;10
  58.         DB    'Invalid Format                            at' ;11
  59.         DB    'Invalid Access Code                       at' ;12
  60.         DB    'Invalid Data                              at' ;13
  61.         DB    'This Error Does Not Exist                 at' ;14
  62.         DB    'Invalid Drive Was Specified               at' ;15
  63.         DB    'Attempted To Remove The Current Directory at' ;16
  64.         DB    'Not Same Device                           at' ;17
  65.         DB    'No More Files                             at' ;18
  66.         DB    'No Room For File(s) On Target Disk        at' ;19
  67.         DB    'No Filename(s) Specified                  at' ;20
  68.         DB    'No Volume Label On Disk                   at' ;21
  69.         DB    'Wrong Number of Parameters                at' ;22
  70.         DB    'No Error for This Value                   at' ;>22
  71. ERRORMSD    Ends
  72.  
  73.     Extrn    PUSHALL:Near
  74.     Extrn    CURS_SET:Near
  75.     Extrn    POPALL:Near
  76.     Extrn    TEXT_WRT:Near
  77.     Extrn    HEX_ASC:Near
  78.     Extrn    HEXDSPLY:Near
  79.     Extrn    SEARCH:Near            ;locates matching strings.
  80.  
  81. ERRORMSC    Segment
  82.     Assume    CS:ERRORMSC,DS:ERRORMSD
  83.     Public    ERRORMSG
  84.  
  85.     Include    CALLM.MAC
  86.  
  87.                         ;notice.
  88.     DB    'ERRORMSG - V1.01, Copyright 1987, CoreTechs   ',0DH,0AH
  89.  
  90. ERRORMSG    Proc    Near
  91.                         ;this section has the effect
  92.                         ;of placing the return address
  93.                         ;for the erroring program on
  94.                         ;the stack as another
  95.                         ;parameter.
  96.     Pop    CS:WORD PTR[0]            ;store return address.
  97.     Pop    CS:WORD PTR[2]            ;store error value.
  98.     Push    CS:WORD PTR[0]            ;replace return address.
  99.     Push    CS:WORD PTR[2]            ;replace error value.
  100.     Push    CS:WORD PTR[0]            ;replace return address.
  101.  
  102.     Call    PUSHALL                ;save registers.
  103.  
  104.     Mov    AX,ERRORMSD            ;setup workarea.
  105.     Mov    DS,AX
  106.  
  107.     Mov    BP,OFFSET MSG            ;load error table offset.
  108.     Pop    AX                ;recover error value.
  109.     Mov    AH,0                ;error is in the range (0-255)
  110.  
  111.     Pop    DX                ;recover IP.
  112.     Push    DX                ;restore IP.
  113.  
  114.                         ;save return address for
  115.     Mov    CALLER,DX            ;error message.
  116.  
  117.     Cmp    AX,0                ;if error is 0, then no error.
  118.     Jnz    ERROR
  119.     Jmp    OUTIN
  120.  
  121. ERROR:    Cmp    AX,MAXERR            ;if error is greater then or
  122.     Jb    ERROR1                ;equal to the highest error
  123.     Mov    AX,MAXERR            ;then use the highest error.
  124.  
  125. ERROR1:    Dec    AX                ;decrement to get offset.
  126.     Mul    NUMBER                ;offset is mult. of NUMBER.
  127.  
  128.     Add    BP,AX                ;find total offset.
  129.  
  130.     Mov    AL,NUMBER            ;find offset to end of mess.
  131.     Mov    AH,0
  132.     Add    AX,BP
  133.  
  134.                         ;display error message.
  135.     Callm    TEXT_WRT,<0,1800H,DS,BP,AX>,
  136.  
  137.     Callm    HEXDSPLY,<CS>,<AX,BX>        ;prepare CS for display.
  138.     Xchg    AH,AL                ;flip bytes.
  139.     Xchg    BH,BL                ;flip bytes.
  140.     Mov    ADDR1,AX            ;store CS.
  141.     Mov    ADDR2,BX
  142.  
  143.     Pop    AX                ;recover IP.
  144.  
  145.     Callm    HEXDSPLY,<AX>,<AX,BX>        ;prepare IP for display.
  146.     Xchg    AH,AL                ;flip bytes.
  147.     Xchg    BH,BL                ;flip bytes.
  148.     Mov    ADDR3,AX            ;store CS.    
  149.     Mov    ADDR4,BX
  150.  
  151.     Mov    BP,OFFSET ADDR1            ;display error address.
  152.     Add    BP,13
  153.     Callm    TEXT_WRT,<0,1830H,DS,<OFFSET ADDR1>,BP>,
  154.  
  155.     Mov    BX,CALLER            ;locate error module.
  156.     Callm    SEARCH,<1,CS,BX,9,DS,<OFFSET SNAME>>,<AX,BX>
  157.  
  158.     Sub    BX,22H                ;display module where error
  159.     Mov    DX,BX                ;occurred.
  160.     Add    DX,8
  161.     Callm    TEXT_WRT,<0,183EH,AX,BX,DX>,
  162.  
  163.                         ;position cursor at bottom
  164.     Callm    CURS_SET,<1800H,0>,        ;of screen at exit.
  165.  
  166.     Mov    AH,4CH                ;return to DOS.
  167.     Int    21H
  168.  
  169. OUTIN:    Pop    AX                ;normal recovery to calling
  170.     Call    POPALL                ;program.
  171.     Ret
  172.  
  173. ERRORMSG    Endp
  174. ERRORMSC    Ends
  175.     End
  176.